def decodeString(s):
    #初始化数据结构
    stack, res, num = [], '', 0
    for c in s:
        if c.isdigit():
            num = num * 10 + int(c)
        elif c.isalpha():
            res += c
        elif c == '[':
            #元组形式入栈
            stack.append((res, num))
            #刷新字符串和重复次数
            res, num = '', 0
        else:
            #如果c==']',弹出字符串和重复次数
            last_str, this_num = stack.pop()
            res = last_str + this_num * res
    return res
decodeString('3[a]2[bc]')

# 正则试试？